from core.item import Item
from core.action import Action
from items.vines import Vines
from core.support import set_cutscene

class Knife(Item):
    def __init__(self):
        Item.__init__(self, "knife")    # do basic initialization for every item
        
        # build list of actions
        self.add_action(UseKnife)
    
    def get_description(self):
        return "pocket knife"

# define actions for this item

class UseKnife(Action):
    def __init__(self):
        Action.__init__(self, "use_knife")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Use knife"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"

    def do_action(self,game,room,request):
        if room.get_id() == 'forest':
            set_cutscene("You cut some vines from the foliage.")
            player = game.get_player()
            player.add_item(Vines())
        else:
            set_cutscene("Nothing to use the knife on here.")
        return